NFC 7 SPI Click
NFC 7 SPI Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Oct 2024.
- Type : SPI type
Software Support
Example Description
This example demonstrates the use of NFC 7 SPI Click board by handling the detection and processing of various NFC technologies and protocols, and ensuring the application can respond to different NFC card types (A,B,F,V).
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.NFC7SPI
Example Key Functions
- nfc7spi_cfg_setup Config Object Initialization function.
void nfc7spi_cfg_setup(nfc7spi_cfg_t *cfg)
NFC 7 SPI configuration object setup function.
NFC 7 SPI Click configuration object.
Definition nfc7spi.h:492
- nfc7spi_init Initialization function.
err_t nfc7spi_init(nfc7spi_t *ctx, nfc7spi_cfg_t *cfg)
NFC 7 SPI initialization function.
NFC 7 SPI Click context object.
Definition nfc7spi.h:464
- nfc7spi_default_cfg Click Default Configuration function.
err_t nfc7spi_default_cfg(nfc7spi_t *ctx)
NFC 7 SPI default configuration function.
- nfc7spi_wait_discovery This function waits until remote NFC device is discovered.
err_t nfc7spi_wait_discovery(nfc7spi_t *ctx, nfc7spi_rf_intf_t *rf_intf)
NFC 7 SPI wait discovery function.
NFC 7 SPI Click discovered remote device properties object.
Definition nfc7spi.h:424
- nfc7spi_presence_check This function waits until the discovered target device is removed.
void nfc7spi_presence_check(nfc7spi_t *ctx, nfc7spi_rf_intf_t *rf_intf)
NFC 7 SPI presence check function.
- nfc7spi_stop_discovery This function stops the RF discovery process.
err_t nfc7spi_stop_discovery(nfc7spi_t *ctx)
NFC 7 SPI stop discovery function.
Application Init
Initializes the driver and logger, performs the Click default configuration and reads the device firmware version.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( SPI_MASTER_ERROR ==
nfc7spi_init( &nfc7spi, &nfc7spi_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_printf( &logger, " FW version: %.2X.%.2X.%.2X\r\n",
( uint16_t ) nfc7spi.fw_version[ 0 ],
( uint16_t ) nfc7spi.fw_version[ 1 ],
( uint16_t ) nfc7spi.fw_version[ 2 ] );
log_info( &logger, " Application Task " );
}
#define NFC7SPI_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition nfc7spi.h:342
void application_init(void)
Definition main.c:90
#define MIKROBUS_POSITION_NFC7SPI
Definition main.c:31
@ NFC7SPI_ERROR
Definition nfc7spi.h:514
Application Task
Waits for an NFC device to be discovered, checks if it supports a known NFC technology, and then handles the device based on its protocol. The application continues processing the device (reading and writing information) and waits until the card is removed. Once the card is removed, the discovery process is restarted to detect a new NFC device.
{
log_printf( &logger, " WAITING FOR DEVICE DISCOVERY\r\n\n" );
{
{
for ( ; ; )
{
nfc7spi_display_card_info ( rf_intf );
{
{
nfc7spi_handle_iso14443_3a ( &nfc7spi );
break;
}
{
nfc7spi_handle_iso14443_4 ( &nfc7spi );
break;
}
{
nfc7spi_handle_iso15693 ( &nfc7spi );
break;
}
{
nfc7spi_handle_mifare ( &nfc7spi );
break;
}
default:
{
break;
}
}
{
break;
}
}
log_printf ( &logger, " - CARD REMOVED\r\n\n" );
}
else
{
log_printf ( &logger, " - WRONG DISCOVERY\r\n\n" );
}
}
}
#define NFC7SPI_NCI_RF_TECH_PASSIVE_POLL_NFC_B
Definition nfc7spi.h:181
#define NFC7SPI_NCI_RF_TECH_PASSIVE_POLL_15693
Definition nfc7spi.h:183
#define NFC7SPI_NCI_RF_PROT_T2T
Definition nfc7spi.h:192
#define NFC7SPI_NCI_RF_PROT_MIFARE
Definition nfc7spi.h:197
#define NFC7SPI_NCI_RF_PROT_T5T
Definition nfc7spi.h:196
#define NFC7SPI_NCI_RF_PROT_ISODEP
Definition nfc7spi.h:194
#define NFC7SPI_NCI_RF_TECH_PASSIVE_POLL_NFC_A
NFC 7 SPI RF technologies and mode setting.
Definition nfc7spi.h:180
#define NFC7SPI_NCI_RF_TECH_PASSIVE_POLL_NFC_F
Definition nfc7spi.h:182
err_t nfc7spi_reader_act_next(nfc7spi_t *ctx, nfc7spi_rf_intf_t *rf_intf)
NFC 7 SPI reader activate next function.
err_t nfc7spi_start_discovery(nfc7spi_t *ctx)
NFC 7 SPI start discovery function.
void application_task(void)
Definition main.c:130
@ NFC7SPI_OK
Definition nfc7spi.h:513
uint8_t more_tags
Definition nfc7spi.h:428
uint8_t protocol
Definition nfc7spi.h:426
uint8_t mode_tech
Definition nfc7spi.h:427
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.